package com.stellar.circle.controller.admin.sPostTag;

import com.stellar.circle.controller.admin.sPostTag.vo.*;
import com.stellar.circle.domain.sPostTag.SPostTagDomainService;

import com.stellar.web.core.bean.PageResult;
import com.stellar.web.core.bean.Result;
import com.stellar.web.core.validator.ValidatorRole;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 话题表控制器
 *
 * @author Jqchan
 * @version 1.0
 * @date 2025-05-17 19:30:33
 */
@RequestMapping("/api-admin/sPostTag")
@RestController("adminSPostTagController")
@Slf4j
public class SPostTagController {

    @Resource
    private SPostTagDomainService sPostTagDomainService;

    /**
     * 分页查询话题表
     */
    @ValidatorRole
    @PostMapping("/page")
    public Result<PageResult<SPostTagResponseVO>> page(@RequestBody SPostTagRequestPageVO requestPageVO) {
        return Result.success(sPostTagDomainService.page(requestPageVO));
    }

    /**
     * 新增话题表
     */
    @ValidatorRole
    @PostMapping("/create")
    public Result<Boolean> create(@RequestBody SPostTagRequestVO requestVO) {
        return Result.success(sPostTagDomainService.insert(requestVO));
    }

    /**
     * 修改话题表
     */
    @ValidatorRole
    @PostMapping("/update")
    public Result<Boolean> update(@RequestBody SPostTagRequestVO requestVO) {
        return Result.success(sPostTagDomainService.update(requestVO));
    }

    /**
     * 删除话题表
     */
    @ValidatorRole
    @DeleteMapping("/delete/{id}")
    public Result<Boolean> delete(@PathVariable("id") Long id) {
        return Result.success(sPostTagDomainService.delete(id));
    }

    /**
     * 获取话题表详情
     */
    @ValidatorRole
    @GetMapping("/get/{id}")
    public Result<SPostTagResponseVO> get(@PathVariable("id") Long id) {
        return Result.success(sPostTagDomainService.get(id));
    }

    /**
     * 获取话题概览接口
     *
     * @return
     */
    @GetMapping("/overview")
    public Result<PostTagOverviewVO> getOverview() {
        return Result.success(sPostTagDomainService.getTagOverview());
    }

    /**
     * 获取热门话题排行
     *
     * @return
     */
    @GetMapping("/hotRank")
    public Result<List<HotTopicVO>> getHotTopics() {
        return Result.success(sPostTagDomainService.getHotTopics());
    }
}
